#ifndef __H_ENVIRONMENT__
#define __H_ENVIRONMENT__

#include "tstring.h"
#include <shlobj.h>
#include <lmcons.h>

namespace bl{

	class Environment
	{
	public:

		enum SpeicalFolder {
			CommonApplicationData,		// C:\Program Data
			DesktopDirectory,				// Desktop directory
			TemporaryDirectory,				// Temporary directory
			ApplicationData,					// Common repository for application data for the current roaming user
			LocalApplicationData			// Application data used by current user, non-roaming user
		};

		static tstring GetFolderPath(SpeicalFolder folder)
		{
			TCHAR szPath[MAX_PATH];
			switch(folder)
			{
			case CommonApplicationData:
				SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, szPath);
				break;
			case DesktopDirectory:
				SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_CURRENT, szPath);
				break;
			case TemporaryDirectory:
				GetTempPath(MAX_PATH, szPath);
				break;
			case ApplicationData:
				SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szPath);
				break;
			case LocalApplicationData:
				SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szPath);
				break;
			default:
				break;
			}

			return szPath;
		}

		static tstring UserName()
		{
			TCHAR sz[UNLEN+1];
			DWORD dwSize = UNLEN+1;
			::GetUserName(sz, &dwSize);
			return sz;
		}

		static unsigned int TickCount()
		{
			return ::GetTickCount();
		}
	};

}

#endif